namespace Extended.NetRouting
{
    /// <summary>
    /// A pair of nodes
    /// </summary>
    public class Route : IRoute
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Route"/> class. Length is set to 1.
        /// </summary>
        public Route() : this(null, null, 1, null)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Route"/> class. Length is set to 1.
        /// </summary>
        public Route(object start, object target) : this(start, target, 1, null)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Route"/> class.
        /// </summary>
        public Route(object start, object target, int length) : this(start, target, length, null)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Route"/> class.
        /// </summary>
        public Route(object start, object target, int length, string tag)
        {
            this.Start = start;
            this.Target = target;
            this.Length = length;
            this.Tag = tag;
        }

        /// <summary>
        /// Gets or sets the starting node of this instance.
        /// </summary>
        public object Start { get; set; }

        /// <summary>
        /// Gets or sets the ending node of this instance.
        /// </summary>
        public object Target { get; set; }

        /// <summary>
        /// Gets or sets the distance between the two nodes.
        /// </summary>
        public int Length { get; set; }

        /// <summary>
        /// Gets or sets a tag that uniquely identifies the route, in case there is another route
        /// in the same network that have the same start and end node (alternative route between two nodes)
        /// </summary>
        public string Tag { get; set; }

        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        public override string ToString()
        {
            var tagSuffix = string.IsNullOrEmpty(this.Tag) ? "(" + this.Tag + ")" : string.Empty;
            return this.Start + ">" + this.Target + tagSuffix;
        }
    }
}